home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 014 / sorts14.arc / SORTS.DOC < prev   
Encoding:
Text File  |  1986-12-09  |  11.2 KB  |  288 lines

  1.            SORTS - A Multi-Key Record Sorting Utility
  2.  
  3.                            Version 1.4
  4.  
  5.              by William C. Parke (c) Copyright 1986
  6.                              for CHUG
  7.               the Capital Heath/Zenith Users' Group
  8.  
  9. INTRODUCTION
  10.  
  11. SORTS is  a record  sorting program  for MS-DOS computer systems.
  12. It will  sort records  from files  larger than  64K in size, with
  13. tens of  thousands of  records (depending  on the  memory in  the
  14. computer), sorting  on an arbitrary set of key fields selected in
  15. any order.   Record  lengths can  be variable,  with  up  to  255
  16. characters in  each.   The sorting  keys can  be from  one to 255
  17. characters long,  taken from columns in the records in any order.
  18. Often used  key-column orders  can  be  saved  within  SORTS  and
  19. recalled by  a single  letter name.  Any part or parts of the key
  20. can be selected for reverse order sorting.
  21.  
  22. The advantages of SORTS are the following:
  23.  
  24. 1.   Speed:   SORTS was  written  in  assembly  language  and  it
  25. performs its  sorts in  memory, making  its operations  very fast
  26. relative to many other sorting programs.
  27.  
  28. 2.   Capacity:   SORTS can handle files with approximately 30,000
  29. records and up to a 7.5 Megabyte file.
  30.  
  31. 3.   Flexibility:  SORTS can perform multiple field sorting based
  32. on a selection of columns making up a sorting key.  Each selected
  33. column can be sorted in reverse order or normal ASCII order.
  34.  
  35. 4.   Ease of Use:  SORTS can save up to 8 set of columns used for
  36. a sorting key.  This setting can be recalled by a single letter.
  37.  
  38. PURPOSE OF SORTS:
  39.  
  40. SORTS is  use to  arrange records  in a  file  in  numerical  and
  41. alphabetical order,  starting at  any position in the record, and
  42. using an  arbitrary set  of columns  to perform  the ordering.  A
  43. record  is  any  set  of  characters  terminated  by  a  carriage
  44. return/line feed.  SORTS does not require the records be of fixed
  45. length, but they must not exceed 255 characters per record.
  46.  
  47. SORTS is  handy for  sorting  disk  catalogs,  name  directories,
  48. numerical data,  address lists, etc. based on selected key fields
  49. within the  records.   It is  probably  the  fastest  multi-field
  50. sorting utility  available.   It gains  speed by using all of the
  51. available free RAM (up to the 640K limit on MS-DOS machines).  It
  52. will not operate on files with more than about 30,000 records.
  53.  
  54. INVOKING SORTS:
  55.  
  56. The command syntax for SORTS is:
  57.  
  58.    SORTS oldfile newfile [/t][/sx][/c1-c2,c3,...]
  59.  
  60. where
  61.         oldfile is the name of the file which stores the unsorted
  62.               records (with optional path name prefix),
  63.         newfile is  the name  of the  file you  wish to  use  for
  64.               storing  the   sorted  records  (newfile  may  also
  65.               contain a path name prefix);
  66.  
  67.         t  is an optional toggle:
  68.           t= C   will make SORTS ignore the case of letters while
  69.               sorting,
  70.  
  71.         s is an optional selection:
  72.           s= Sx  indicates that the column order which follows is
  73.               to be saved and given the name 'x',
  74.           s= Ux     indicates that  the previously  saved  column
  75.               order 'x' is to be used for the present sort;
  76.  
  77.         c1-c2,c3,... are  optional column  numbers, starting at 1
  78.               for the  first column in the record. The pair c1-c2
  79.               makes the columns from c1 to c2 (inclusive) part of
  80.               the sorting  key.   The single  value like c3 above
  81.               adds the  single column  at c3  to the  key.  If no
  82.               columns are  given, a  default of  columns 1-12  is
  83.               assumed.
  84.         If an  R appears  in front  of any pair of column numbers
  85.               (or in  front of  a singular  column number),  that
  86.               column range  (or single  column) will be sorted in
  87.               reverse ASCII order.
  88.  
  89. EXAMPLES:
  90.  
  91. 1. Getting a reminder of SORTS' syntax and stored fields:
  92.  
  93.         SORTS
  94.  
  95. will give a brief help screen indicating the syntax for SORTS and
  96. will show  the current  names and  values of  the  stored  column
  97. orders to  make key  fields.   This same  help  screen  is  shown
  98. whenever a command line syntax error occurs. The initial settings
  99. for the  stored column orders  match  the  columns  used  in  the 
  100. companion program  CATS,  used to catalog a large number of files
  101. on multiple disks.
  102.  
  103. 2. Sorting by default:
  104.  
  105.         SORTS NAM.REC NAME.REC
  106.  
  107. will sort  the records  in the  file NAM.REC,  using the  default
  108. first 12  columns of  each record  as a  key field.   The  sorted
  109. records will be written to NAME.REC.
  110.  
  111. 3. Sorting with new key field:
  112.  
  113.         SORTS FOO.BAR FOOD.BAR/8-10,r1-3,40,43,50-60
  114.  
  115. will sort  the records  in the file FOO.BAR, using a key based on
  116. the columns:
  117.  
  118.    8,9,10,1,2,3,40,43,50,51,52,53,54,55,56,57,58,59,60
  119.  
  120. in that  order, in  FOO.BAR.   This operation will produce a file
  121. FOOD.BAR with  all 'A's  in column  8 before 'B's, etc.  For each
  122. record with  a given  sequence in  columns 8,  9, and 10, records
  123. with a  'Z' in  column 1  will come before those with a 'Y', etc.
  124. Specifying multiple  columns  in  this  way  has  the  effect  of
  125. performing a  multiple  number  of  sorts  on  each  key  subset,
  126. preserving the previously sorted fields.
  127.  
  128. 4.  Defining a new key field column order:
  129.  
  130.         SORTS /Sa/r14-15,1-8,10
  131.  
  132. will save  the column  order settings r14-15,1-8,10 into a buffer
  133. in SORTS  with the  name 'a'.   (The 'a' can be in upper or lower
  134. case.)   This setting can be reviewed with the command SORTS with
  135. no command tail as in the first example above.
  136.  
  137. 5.  Defining and operating with a new key field column order:
  138.  
  139.         SORTS MAY.DIG MAYBE.DIG/Sm/20-24,1-8
  140.  
  141. will save  the key  columns 20-24,1-8 with name 'm' and then sort
  142. the records in MAY.DIG according to this key.
  143.  
  144. 6.  Ignoring case while sorting:
  145.  
  146.         SORTS \CATS\CATS.DIR CATST.DIR/C/UT
  147.  
  148. will sort  the file  CATS.DIR in the directory called CATS, using
  149. the previously  set column order named 't', and ignoring the case
  150. of the characters.
  151.  
  152. 7.  Erasing a previously defined column order:
  153.  
  154.         SORTS /Sa/0
  155.  
  156. will erase  the column  order labeled 'a' from the storage buffer
  157. in SORTS.   This  will make  space for  a new column order with a
  158. different label.
  159.  
  160. SORTS OPERATION
  161.  
  162. After the  program begins,  SORTS will show the key field columns
  163. it will use for the sorting.  It then calculates and displays the
  164. total number  of records which could be sorted with the given key
  165. field length,  assuming resident  programs are  not  loaded  into
  166. memory.   SORTS follows by showing how many records can be sorted
  167. with the  current free  memory.  Next, the output file is opened.
  168. If it  already exits,  you will be asked if you wish to overwrite
  169. it.   Then, the  key fields  of the file records to be sorted are
  170. read into memory.  SORTS will display the total number of records
  171. it has  found, and check if enough memory is available to perform
  172. the sort.   If so, the sorting is done in memory. The file is re-
  173. read in record sorted form to be written to the output file.
  174.  
  175. SORTING CONSIDERATIONS
  176.  
  177. Key field  lengths from 1 to 12 will permit the largest number of
  178. records to be sorted.  With a total key field length of 13 to 28,
  179. only half  that number  can be  sorted.   When picking columns by
  180. examining sample  records to be sorted, try to keep the total key
  181. field length  in the  1-12 range.   If  this is not possible, you
  182. should then  try to  use less  than 29 columns for the key field.
  183. For example, if a record had the following format (column numbers
  184. are given above record):
  185.  
  186.          1         2         3         4         5
  187. 12345678901234567890123456789012345678901234567890
  188. FOOBAR   EXE     89984 83/11-30 01:23 DISK 000001\.........
  189.  
  190. then sorting  on the date and time field (24-37) can be done with
  191. the key  columns set  to either  24-37, or  24-25,27-28,30-31,33-
  192. 34,36-37.   This second  choice eliminates the '/', '-', and ' ',
  193. and ':'  characters which are repeated in every record and do not
  194. affect a record sort anyway.  Instead of (24-37), which has a key
  195. width of  14, the segmented set has a width of only 10, leaving 2
  196. more columns  available to make a 12 or less character key.  Note
  197. that SORTS starts column numbers at 1 rather than 0.
  198.  
  199. For some  purposes, a  restricted sub-key  field produces  a more
  200. interesting sorted  file than a wider field.  With records in the
  201. format of the above example, taking the 'year' field (columns 24-
  202. 25) rather  than the  full date (columns 24-31) as the first part
  203. of a  column order,  such as  24-25,1-12, produces  a sorted file
  204. with  all   records  in   one  year  grouped  together  and  then
  205. alphabetized by the names in the columns 1-12..
  206.  
  207. SORTS ERROR MESSAGES
  208.  
  209. Column order "x" in use.  Overwrite it ?
  210.         The selection  /Sx was  made for  a column  order already
  211.         defined.
  212.         
  213. Column order "x" not found.
  214.         The selection  /Ux was  made for  a column  order not yet
  215.         defined.
  216.         
  217. Column syntax error.
  218.         The format  of the  /c1-c2,c3,... column  order  was  not
  219.         correct.  See the examples above for the correct syntax.
  220.         
  221. Erase column order "x" ?
  222.         A request  to overwrite  a previously define column order
  223.         was made with the /Sx selection.
  224.         
  225. Error opening [filename]
  226.         The input file specified was not found.
  227.         
  228. Error Reading file
  229.         An error occurred in attempting to read the input file.
  230.         
  231. Error Writing sorted file
  232.         An error occurred in attempting to write the output file.
  233.         
  234. Insufficient memory.
  235.         SORTS did  not find enough free RAM for its required file
  236.         buffers.
  237.         
  238. Invalid DOS Version.
  239.         SORTS requires MS-DOS 2.1 or above.
  240.         
  241. Maximum 16 column pairs exceeded.
  242.         Too many column pairs were given on the command line.
  243.         
  244. No free new column space.
  245.         All of  the column order settings have been defined.  Use
  246.         the /Sx/0 command to erase one of them.
  247.         
  248. Output file already exits. Overwrite it ?
  249.         Overwriting the  output file  will destroy  any  previous
  250.         data in that file.  The input file is unaffected.
  251.         
  252. Output file cannot be input file.
  253.         The output  file was  given the  same name  as the  input
  254.         file.  SORTS cannot operate on just one file.
  255.         
  256. S selection requires column order.
  257.         The /Sx  selection must  be followed  by a  column  order
  258.         definition: /c1-c2,c3,...
  259.         
  260. SORTS.COM not found.
  261.         If a  /Sx selection is to save a column order, SORTS must
  262.         be able to find itself on the disk.
  263.         
  264. U selection takes no column order.
  265.         The /Ux  selection uses  a previously  defined and  saved
  266.         column order  definition.   No /c1-c2,c3... should follow
  267.         this selection.
  268.  
  269.  
  270. Acknowledgement:
  271.  
  272.      This program was inspired by a sorting utility by Vernon Buerg.
  273. Jerome Horwitz  and  Douglas Clark  in  CHUG  gave suggestions  and
  274. encouragement.
  275.  
  276.  
  277. Copyright Status:
  278.  
  279. The author retains all legal Copyrights to the program SORTS Version 1.4.
  280. However, he grants individuals licence to use this program, and permits
  281. non-profit and non-commercial distribution of the program.
  282.  
  283. Please send comments to:
  284.  
  285.         William C. Parke
  286.         1820 S Street NW
  287.         Washington, D.C. 20009
  288.